package org.example.view.Frame;

import org.example.view.componet.ATMButton;
import org.example.view.componet.BackgroundScene;
import org.example.view.componet.ButtonTypeEnum;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;

/**
 * 查询页面
 */
public class FindAtm extends JPanel {
    /**
     * 背景
     */
    private BackgroundScene backgroundScene;

    /**
     * 操作框
     */
    private JLabel pane;

    /**
     * 余额
     */
    private JLabel money;

    /**
     * 提示
     */
    private JLabel hint;

    /**
     * 退出按钮
     */
    private ATMButton offButton;

    public FindAtm(JPanel panel) {
        this.addContent(panel);
    }

    private void addContent(JPanel panel) {
        this.setLayout(null);

        /**
         * 退出按钮（跳转选择页面）
         */
        this.offButton = new ATMButton(ButtonTypeEnum.退出, 450, 650);
        this.offButton.addActionListener(new AbstractAction() {
            @Override
            public void actionPerformed(ActionEvent e) {
                CardLayout cardLayout = (CardLayout) panel.getLayout();
                cardLayout.show(panel, "choose");
            }
        });
        this.add(this.offButton);

        /**
         * 余额
         */
        this.money = new JLabel();
        this.money.setText("余额：");
        this.money.setFont(new Font("宋体", Font.ITALIC, 40));
        this.money.setForeground(Color.blue);
        this.money.setBounds(300, 310, 260, 50);
        this.add(this.money);

        /**
         * 提示
         */
        this.hint = new JLabel();
        this.hint.setText("点击退出转移到选择业务界面");
        this.hint.setFont(new Font("宋体", Font.ITALIC, 12));
        this.hint.setForeground(Color.red);
        this.hint.setBounds(410, 380, 200, 20);
        this.add(this.hint);

        /**
         * 操作框
         */
        this.pane = new JLabel(new ImageIcon("/Users/cengyunke/Desktop/atm1/ATMGUI/src/main/java/org/example/img/pane.jpg"));
        this.pane.setBounds(210, 250, 620, 200);
        this.add(this.pane);

        /**
         * 背景
         */
        this.backgroundScene = new BackgroundScene();
        this.add(this.backgroundScene);
    }
}
